package com.example.edu.Dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Return {
    int retcode; //0为成功，不同情况的错误不同码
    String message;
    Object data;
    int total;

    public static Return ok(){
        return new Return(0,null,null,0);
    }

    public static Return ok(Object data){
        return new Return(0,null,data,1);
    }

    public static Return ok(String message, Object data){
        return new Return(0,message,data,0);
    }

    public static Return ok(List<?> data){
        return new Return(0,null,data,data.size());
    }

    public static Return fail(int retcode, String message){
        return new Return(retcode,message,null,0);
    }
}
